{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters %}
<table class="table table-sm table-striped tablesorter ipr-table">
    <thead>
        <tr>
            <th scope="col" data-sort="date">Date</th>
            <th scope="col" data-sort="num">ID</th>
            <th scope="col" data-sort="title">Title</th>
            {% if administrative_list == 'pending' %}
                <th scope="col" data-sort="query">Query</th>
                <th scope="col" data-sort="due">Response due</th>
            {% endif %}
        </tr>
    </thead>
    {% if iprs %}
        <tbody>
            {% for ipr in iprs %}
                <tr>
                    <td class="text-end">{{ ipr.time|date:"Y-m-d" }}</td>
                    <td class="text-end">{{ ipr.id }}</td>
                    <td>
                        {% if ipr.state_id == 'posted' or administrative_list %}
                            <div>
                                <a href="{% url "ietf.ipr.views.show" ipr.id %}">{{ ipr.title }}</a>
                            </div>
                            {% for item in ipr.relatedipr_source_set.all %}
                                {% if item.target.state_id == 'posted' %}
                                    <small>Updates ID
                                        <a href="{% url "ietf.ipr.views.show" item.target.id %}">#{{ item.target.id }}</a>.
                                    </small>
                                {% endif %}
                            {% endfor %}
                            {% for item in ipr.relatedipr_target_set.all %}
                                {% if item.source.state_id == "posted" %}
                                    <small>Updated by ID
                                        <a href="{% url "ietf.ipr.views.show" item.source.id %}">#{{ item.source.id }}</a>.
                                    </small>
                                {% endif %}
                            {% endfor %}
                        {% elif ipr.state_id == 'removed' %}
                            <div>{{ ipr.title }}</div>
                            <small><i>This IPR disclosure was removed at the request of the submitter.</i></small>
                        {% elif ipr.state_id == 'removed_objfalse' %}
                            <div>{{ ipr.title }}</div>
                            <small><i>This IPR disclosure was removed as objectively false.</i></small>
                        {% endif %} {# Intentionally not emitting anything for any other states #}
                    </td>
                    {% if administrative_list == 'pending' %}
                        {% with ipr.get_latest_event_msgout as latest_msgout %}
                            <td>
                                {% if latest_msgout %}{{ latest_msgout.time|date:"Y-m-d" }}{% endif %}
                            </td>
                            <td>
                                {% if latest_msgout and latest_msgout.response_due %}
                                    {{ latest_msgout.response_due|date:"Y-m-d" }}
                                    {% if latest_msgout.response_past_due %}
                                        <i class="bi bi-exclamation-circle" title="Response overdue"></i>
                                    {% endif %}
                                {% endif %}
                            </td>
                        {% endwith %}
                    {% endif %}
                </tr>
            {% endfor %}
        </tbody>
    {% endif %}
</table>